# fout = open('relativity','wt')
# fout.write(poem)
# fout.close()

# fout = open('relativity','wt')
# size = len(poem)
# offset = 0
# chunk = 100
#
# while True :
#     if offset > size :
#         break
#     fout.write(poem[offset:offset+chunk])
#     offset += chunk
#
# fout.close()
# poem = '''There was a young lady named Bright,
#     Whose speed was far faster than light;
#     She started one day
#     In a relative way,
#     And returned on the previous night.'''
# fin = open('relativity','rt')
# poem = fin.read()
# fin.close()
# print(poem)


# fout = open('relativity','xt')
# try:
#     fout = open('relativity','xt')
#     fout.write('stomp stomp stomp')
# except FileExistsError:
#     print('relativity already exists!. That was a close one.')
#
# poem = ''
# fin = open('relativity', 'rt' )
# while True:
#     line = fin.readline()
#     if not line:
#         break
#     poem += line
# fin.close()
#
#
# print(poem)



# poem = ''
# fin = open('relativity','rt')
# for line in fin:
#     poem += line
# print(poem)

# bdata = bytes(range(0, 256))
# print(len(bdata))

# fout = open('bfile', 'wb')
# fout.write(bdata)
# fout.close()

# fout = open('bfile', 'wb')
# bdata = bytes(range(0, 256))
# size = len(bdata)
# offset = 0
# chunk = 100
# while True:
#     if offset > size:
#         break
#     fout.write(bdata[offset:offset+chunk])
#     offset += chunk
# fout.close()
#
# fin = open('bfile', 'rb')
# bdata = fin.read()
# fin.close()
#
# print(bdata)

# fin = open('bfile', 'rb')
# print(fin.seek(255))


# print(fin.tell())


# import os
# print(os.SEEK_CUR)


# villains = [
#     ['Doctor','No'],
#     ['Rosa','Klebb'],
#     ['Mister','Big'],
#     ['Auric','Goldfinger'],
#     ['Ernst', 'Blofeld'],
# ]
# with open('villains','wt') as fout :
#     csvout = csv.writer(fout)
#     csvout.writerows(villains)

# import csv
# with open('villains','rt') as fin :
#     cin = csv.reader(fin)
#     villains = [row  for row in cin ]
# print(villains)

# import csv
# with open('villains','rt') as fin:
#     cin = csv.DictReader(fin,fieldnames=['first','last'])
#     villains = [row  for row in cin ]
# print(villains)


# import xml.etree.ElementTree as et
# tree = et.ElementTree(file='menu.xml')
# root = tree.getroot()
# print(root.tag)
#
# for child in root :
#     print("tag:",child.tag,'attributes:',child.attrib)
#     for grandchild in child :
#         print('\ttag:',grandchild.tag,'attributes',grandchild.attrib)

# import json
# menu = {
#     "breakfast": {
#         "hours" : "17-11",
#         "items" : {
#             "breakfast burritos" : "$6.00",
#             "pancakes" : "$4.00"
#         }
#     },
#     "lunch" : {
#         "hours": "11-3",
#         "items": {
#             "hamburger": "$5.00"
#         }
#     },
#     "dinner": {
#         "hours": "3-10",
#         "items":{
#             "spaghetti": "$8.00"
#         }
#     }
# }
# menu_json = json.dumps(menu)
#
#
# menu2 = json.loads(menu_json)
# print(menu2)

# import datetime
# import json
# now = datetime.datetime.utcnow()
# from time import mktime
# now_epoch = int(mktime(now.timetuple()))
# print(json.dumps(now_epoch))

# import time
# now = time.time()
# print(now)
# days = ['2013-02-25', '2013-02-26', '2013-02-27']
# big_spender = 1089
# tire_kicker = 40459
# late_joiner = 550212
# conn.setbit(days[0], big_spender, 1)


# test1 = 'This is a test of the emergency text system'

# outfile = open('test.txt','xt')
# outfile.write(test1)
# outfile.close()
# with open('test.txt','wt') as outfile :
#     outfile.write(test1)
#
# with open('test.txt', 'rt') as infile:
#     test2 = infile.read()
#
# print(test1 == test2)

# text = '''author,book
# J R R Tolkien,The Hobbit
# Lynne Truss,"Eats, Shoots & Leaves'''
#
# with open('test.csv','wt') as outfile :
#    outfile.write(text)
# import csv
# with open('test.csv','rt') as infine:
#     books = csv.DictReader(infine)
#     for book in books :
#         print(book)

text = '''
        title,author,year
        The Weirdstone of Brisingamen,Alan Garner,1960
        Perdido Street Station,China Miéville,2000
        Thud!,Terry Pratchett,2005
        The Spellman Files,Lisa Lutz,2007
        Small Gods,Terry Pratchett,1992
     '''
with open('book.csv','wt') as outfile :
    outfile.write(text)



